<!DOCTYPE html>
<html>
<head>
<title>登录</title>
<meta name="Keywords" content="关键字">
<meta name="Description" content="内容">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
<meta content="no-cache,must-revalidate" http-equiv="Cache-Control">
<meta content="telephone=no, address=no" name="format-detection">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta content="no-cache" http-equiv="pragma">
<meta content="0" http-equiv="expires">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/home/css/style.css" media="all"> 
<script type="text/javascript" src="__PUBLIC__/home/js/jquery-1.9.1.min.js"></script> 
<script type="text/javascript" src="__PUBLIC__/home/js/size.js"></script>
</head>
<body>
<div class="loginform">
  <div class="box">
    <h1 class="logo"><img src="__PUBLIC__/home/images/logo.png"></h1> 
    <div class="title"><img src="__PUBLIC__/home/images/title.png"></div>
    <ul>
        <li><input name="mobile" id="mobile" type="text" placeholder="手机号码" class="intxt ico-tel"></li>
        <li class="code"><input name="code" id="code" type="text" placeholder="验证码" class="intxt ico-yzm"><input id="btnSendCode1" type="button" class="btn-default" value="发送" onClick="sendMessage1()" /></li>
    </ul>
    <div class="btnbox"><input name="sub" type="button" id="sub" class="btn" value="登    录"></div>
  </div>  
</div>
<script>
var count = 60; //间隔函数，1秒执行
var InterValObj1; //timer变量，控制时间
var curCount1;//当前剩余秒数
			/*第一*/
function sendMessage1() {
    curCount1 = count;		 		 
    //设置button效果，开始计时
    
    
    var mobile=$("#mobile").val();
    

    if(mobile == ''){
    	alert('请输入手机号');
    	return false;
    }

	$.post('smscode',{'mobile':mobile},function(d){
		if(d.status == true){
			$("#btnSendCode1").attr("disabled", "true");
    		$("#btnSendCode1").addClass("disabled");
    		$("#btnSendCode1").val( + curCount1 + "秒");
			InterValObj1 = window.setInterval(SetRemainTime1, 1000); //启动计时器，1秒执行一次
			return false;
		}else{
			alert(d.msg);
			return false;
		}
	},"json");



}
 function SetRemainTime1() {
    if (curCount1 == 0) {                
        window.clearInterval(InterValObj1);//停止计时器
        $("#btnSendCode1").removeAttr("disabled");//启用按钮
        $("#btnSendCode1").removeClass("disabled");
        $("#btnSendCode1").val("重新发送");
    }
    else {
        curCount1--;
        $("#btnSendCode1").val( + curCount1 + "秒");
    }
} 

$("#sub").click(function(){
    var code=$("#code").val();
    var mobile=$("#mobile").val();

    if(mobile == ''){
        alert('请输入手机号');
        return false;
    }

    if(code == ''){
        alert('请输入验证码');
        return false;
    }

    $.post('do_login',{'mobile':mobile,'code':code},function(d){
        if(d.status == true){
            location.href="/home/index/index";
            return false;
        }else{
            alert(d.msg);
            return false;
        }
    },"json");
})
 
</script>
</body>
</html>